const webpack = require('webpack');
const HtmlWebpackPlugin = require('html-webpack-plugin')


var path = require('path');
module.exports = {
  mode: "production",
  entry: {
    main: './main.js'
  },
  output: {
    path: path.join(__dirname, "build"),
    publicPath: './',
    filename: '[name].js'
  },
  module: {
    rules: [
      {
        test: /\.(m?js)|(jsx)$/,
        exclude: /(node_modules|bower_components)/,
        use: {
          loader: 'babel-loader',
          options: {
            presets: ['@babel/preset-env', "@babel/preset-react"],
            plugins: [
              '@babel/plugin-transform-runtime'
            ]
          }
        }
      }
    ]
  },
  // 配置插件
  plugins: [
    new HtmlWebpackPlugin({
      filename: 'index.html', // 目标文件名
      template: './index.html' // 源文件路径
    })
  ]
};